import React, { Component } from 'react'
import  {connect} from  "react-redux"
import  {asyncAddUser} from  "../action/userAction"

 class AddUser extends Component<any, any> {
    constructor(props: any) {
        super(props);
        this.state = {
            username: "",
            userpwd: ""
        }
    }
    add  =async ()=>{

        let  res  = await  this.props.asyncAddUser({
            username:this.state.username,
            userpwd:this.state.userpwd
        })
        alert(res.msg);
      
    }
    render() {
        return (
            <div>
                <h2>AddUser</h2>
                <div>
                    用户名   <input value={this.state.username} onChange={(e) => {
                        this.setState({
                            username: e.target.value
                        })

                    }} />
                </div>
                <div>
                    密码   <input value={this.state.userpwd} onChange={(e) => {
                        this.setState({
                            userpwd: e.target.value
                        })

                    }} />
                </div>
                <button onClick={()=>{
                    this.add()  
                }}>新增</button>
            </div>
        )
    }
}
let  a  = ()=>{
    return  {}
};
let  b={
    asyncAddUser
}

export default   connect(a,b)(AddUser);
